#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# @(#) Makefile.in 1.23 95/06/08 13:13:36

# Current Tcl version;  used in various names.

VERSION = 7.4

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
# the configuration script).
#----------------------------------------------------------------

# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix).  The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.

prefix =	@prefix@
exec_prefix =	@exec_prefix@

# The following definition can be set to non-null for special systems
# like AFS with replication.  It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time.  INSTALL_ROOT is prepended to $prefix and $exec_prefix
# when installing files.
INSTALL_ROOT =

# Directory from which applications will reference the library of Tcl
# scripts (note: you can set the TCL_LIBRARY environment variable at
# run-time to override this value):
TCL_LIBRARY =	$(prefix)/lib/tcl$(VERSION)

# Path name to use when installing library scripts:
SCRIPT_INSTALL_DIR =	$(INSTALL_ROOT)$(TCL_LIBRARY)

# Directory in which to install the archive libtcl.a:
LIB_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/lib

# Directory in which to install the program tclsh:
BIN_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/bin

# Directory in which to install the include file tcl.h:
INCLUDE_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/include

# Top-level directory in which to install manual entries:
MAN_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/man

# Directory in which to install manual entry for tclsh:
MAN1_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man1

# Directory in which to install manual entries for Tcl's C library
# procedures:
MAN3_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man3

# Directory in which to install manual entries for the built-in
# Tcl commands:
MANN_INSTALL_DIR =	$(MAN_INSTALL_DIR)/mann

# To change the compiler switches, for example to change from -O
# to -g, change the following line:
CFLAGS = -O

# To disable ANSI-C procedure prototypes reverse the comment characters
# on the following lines:
PROTO_FLAGS =
#PROTO_FLAGS = -DNO_PROTOTYPE

# Mathematical functions like sin and atan2 are enabled for expressions
# by default.  To disable them, reverse the comment characters on the
# following pairs of lines:
MATH_FLAGS =
#MATH_FLAGS = -DTCL_NO_MATH
MATH_LIBS = @MATH_LIBS@
#MATH_LIBS =

# To compile for non-UNIX systems (so that only the non-UNIX-specific
# commands are available), reverse the comment characters on the
# following pairs of lines.  In addition, you'll have to provide your
# own replacement for the "panic" procedure (see panic.c for what
# the current one does).
GENERIC_FLAGS =
#GENERIC_FLAGS = -DTCL_GENERIC_ONLY
UNIX_OBJS = panic.o tclEnv.o tclGlob.o tclMain.o tclMtherr.o \
	tclUnixAZ.o tclUnixStr.o tclUnixUtil.o
#UNIX_OBJS =

# To enable memory debugging reverse the comment characters on the following
# lines.  Warning:  if you enable memory debugging, you must do it
# *everywhere*, including all the code that calls Tcl, and you must use
# ckalloc and ckfree everywhere instead of malloc and free.
MEM_DEBUG_FLAGS =
#MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG

# Some versions of make, like SGI's, use the following variable to
# determine which shell to use for executing commands:
SHELL =		/bin/sh

# Tcl used to let the configure script choose which program to use
# for installing, but there are just too many different versions of
# "install" around;  better to use the install-sh script that comes
# with the distribution, which is slower but guaranteed to work.

INSTALL = @srcdir@/install-sh -c

#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in.  You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

COMPAT_OBJS =		@LIBOBJS@
AC_FLAGS =		@DEFS@
INSTALL_PROGRAM =	@INSTALL_PROGRAM@
INSTALL_DATA =		@INSTALL_DATA@
RANLIB =		@RANLIB@
SRC_DIR =		@srcdir@
VPATH =			@srcdir@

#----------------------------------------------------------------
# The information below should be usable as is.  The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------


CC =		@CC@
CC_SWITCHES =	${CFLAGS} -I. -I${SRC_DIR} ${AC_FLAGS} ${MATH_FLAGS} \
${GENERIC_FLAGS} ${PROTO_FLAGS} ${MEM_DEBUG_FLAGS} \
-DTCL_LIBRARY=\"${TCL_LIBRARY}\"

GENERIC_OBJS =	regexp.o tclAsync.o tclBasic.o tclCkalloc.o \
	tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclExpr.o tclGet.o \
	tclHash.o tclHistory.o tclLink.o tclParse.o tclProc.o \
	tclUtil.o tclVar.o

OBJS = ${GENERIC_OBJS} ${UNIX_OBJS} ${COMPAT_OBJS}

SRCS= regexp.c tclAsync.c tclBasic.c tclCkalloc.c \
	tclCmdAH.c tclCmdIL.c tclCmdMZ.c tclExpr.c tclGet.c \
	tclHash.c tclHistory.c tclLink.c tclParse.c tclProc.c \
	tclUtil.c tclVar.c panic.c tclEnv.c tclGlob.c tclMain.c \
	tclMtherr.c tclUnixAZ.c tclUnixStr.c tclUnixUtil.c \
	tclTest.c tclAppInit.c

all: libtcl.a tclsh

libtcl.a: ${OBJS}
	rm -f libtcl.a
	ar cr libtcl.a ${OBJS}
	$(RANLIB) libtcl.a

tclsh: tclAppInit.o libtcl.a
	${CC} ${CC_SWITCHES} tclAppInit.o libtcl.a ${MATH_LIBS} -o tclsh

tcltest: tclTest.o libtcl.a
	${CC} ${CC_SWITCHES} tclTest.o libtcl.a ${MATH_LIBS} -o tcltest

test: tcltest
	@cwd=`pwd`; \
	cd $(SRC_DIR); TCL_LIBRARY=`pwd`/library; export TCL_LIBRARY; \
	cd $$cwd; ( echo cd $(SRC_DIR)/tests\; source all ) | ./tcltest

configInfo: Makefile
	@rm -f configInfo
	@echo "# Definitions and libraries needed to build Tcl applications" >> configInfo
	@echo "# (generated by the configure script):" >> configInfo
	@echo "TCL_CC_SWITCHES = ${AC_FLAGS} ${MEM_DEBUG_FLAGS}" >> configInfo
	@echo "TCL_LIBS = ${MATH_LIBS} @LIBS@" >> configInfo

install: install-binaries install-libraries install-man

install-binaries: libtcl.a tclsh
	@for i in $(LIB_INSTALL_DIR) $(BIN_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@echo "Installing libtcl.a"
	@$(INSTALL_DATA) libtcl.a $(LIB_INSTALL_DIR)/libtcl$(VERSION).a
	@$(RANLIB) $(LIB_INSTALL_DIR)/libtcl$(VERSION).a
	@echo "Installing tclsh"
	@$(INSTALL_PROGRAM) tclsh $(BIN_INSTALL_DIR)/tclsh$(VERSION)

install-libraries:
	@for i in $(INSTALL_ROOT)$(prefix)/lib $(INCLUDE_INSTALL_DIR) \
		$(SCRIPT_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@echo "Installing tcl.h"
	@$(INSTALL_DATA) $(SRC_DIR)/tcl.h $(INCLUDE_INSTALL_DIR)
	@for i in $(SRC_DIR)/library/*.tcl $(SRC_DIR)/library/tclIndex $(SRC_DIR)/tclAppInit.c; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR); \
	    done;

install-man:
	@for i in $(MAN_INSTALL_DIR) $(MAN1_INSTALL_DIR) $(MAN3_INSTALL_DIR) $(MANN_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@cd $(SRC_DIR)/doc; for i in *.1; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MAN1_INSTALL_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MAN1_INSTALL_DIR)/$$i; \
	    chmod 444 $(MAN1_INSTALL_DIR)/$$i; \
	    done;
	@cd $(SRC_DIR)/doc; for i in *.3; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MAN3_INSTALL_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MAN3_INSTALL_DIR)/$$i; \
	    chmod 444 $(MAN3_INSTALL_DIR)/$$i; \
	    done;
	@cd $(SRC_DIR)/doc; for i in *.n; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MANN_INSTALL_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MANN_INSTALL_DIR)/$$i; \
	    chmod 444 $(MANN_INSTALL_DIR)/$$i; \
	    done;

Makefile: $(SRC_DIR)/Makefile.in
	$(SHELL) config.status

clean:
	rm -f *.a *.o core errs *~ \#* TAGS *.E a.out errors tclsh tcltest \
		config.info

distclean: clean
	rm -f Makefile config.status config.cache

depend:
	makedepend -- $(CC_SWITCHES) -- $(SRCS)

fixstrtod.o: $(SRC_DIR)/compat/fixstrtod.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/fixstrtod.c

getcwd.o: $(SRC_DIR)/compat/getcwd.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/getcwd.c

opendir.o: $(SRC_DIR)/compat/opendir.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/opendir.c

strerror.o: $(SRC_DIR)/compat/strerror.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/strerror.c

strncasecmp.o: $(SRC_DIR)/compat/strncasecmp.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/strncasecmp.c

strstr.o: $(SRC_DIR)/compat/strstr.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/strstr.c

strtod.o: $(SRC_DIR)/compat/strtod.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/strtod.c

strtol.o: $(SRC_DIR)/compat/strtol.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/strtol.c

strtoul.o: $(SRC_DIR)/compat/strtoul.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/strtoul.c

tmpnam.o: $(SRC_DIR)/compat/tmpnam.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/tmpnam.c

waitpid.o: $(SRC_DIR)/compat/waitpid.c
	$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/compat/waitpid.c

.c.o:
	$(CC) -c $(CC_SWITCHES) $<

#
# Target to check for proper usage of UCHAR macro.
#

checkuchar:
	-egrep isalnum\|isalpha\|iscntrl\|isdigit\|islower\|isprint\|ispunct\|isspace\|isupper\|isxdigit $(SRCS) | grep -v UCHAR

#
# Target to make sure that only symbols with "Tcl" prefixes are
# exported.
#

checkexports: libtcl.a
	-nm -p libtcl.a | awk '$$2 ~ /[TDB]/ { print $$3 }' | sort -n | grep -v '^[Tt]cl'

#
# Target to create a proper Tcl distribution from information in the
# master source directory.  DISTDIR must be defined to indicate where
# to put the distribution.
#

configure: configure.in
	autoconf
dist: configure
	rm -rf $(DISTDIR)
	mkdir $(DISTDIR)
	cp Makefile.in $(DISTDIR)
	chmod 664 $(DISTDIR)/Makefile.in
	cp -p $(SRCS) $(DISTDIR)
	cp -p tclRegexp.h tcl.h tclInt.h tclPort.h patchlevel.h $(DISTDIR)
	cp configure configure.in $(DISTDIR)
	chmod 775 $(DISTDIR)/configure $(DISTDIR)/configure.in
	cp -p changes README porting.notes porting.old license.terms \
		install-sh $(DISTDIR)
	chmod +x $(DISTDIR)/install-sh
	mkdir $(DISTDIR)/library
	cp -p license.terms library/*.tcl library/tclIndex $(DISTDIR)/library
	mkdir $(DISTDIR)/doc
	cp -p license.terms doc/*.[13n] doc/man.macros $(DISTDIR)/doc
	mkdir $(DISTDIR)/compat
	cp -p license.terms compat/*.c compat/*.h compat/README \
		$(DISTDIR)/compat
	mkdir $(DISTDIR)/tests
	cp -p license.terms $(DISTDIR)/tests
	cp -p tests/*.test tests/README tests/all tests/defs $(DISTDIR)/tests

# DO NOT DELETE THIS LINE -- make depend depends on it.
